package com.pickgliss.ui.image
{
	import com.pickgliss.ui.core.Component;
	
	import flash.display.Shape;

	public class DrawImage extends Image
	{
		private const CIRCLE:String="circle"
		private const RECT:String="rectangle";
		private const TRIANGLES:String="triangles"
		public static const P_ellipseWidth:String = "ellipseWidth";
		public static const P_ellipseHeight:String = "ellipseHeight";
		
		public var imageStyle:String
		
		public var color:uint
		
		public var imageAlpha:Number
		
		
		
		//圆角长方形的顶角弧度
		protected var _ellipseWidth:int
		
		protected var _ellipseHeight:int
		
		 public function get ellipseWidth():int
		{
			return _ellipseWidth;
		}
		
		 public function set ellipseWidth(el:int):void
		{
			if (el == _ellipseWidth)
				return;
			_ellipseWidth = el;
			onPropertiesChanged(P_ellipseWidth);
		}
		
		 public function get ellipseHeight():int
		{
			return _ellipseHeight;
		}
		
		 public function set ellipseHeight(el:int):void
		{
			if (el == _ellipseHeight)
				return;
			_ellipseHeight = el;
			onPropertiesChanged(P_ellipseHeight);
		}
		
		
			
		
			
			
			
			
		public function DrawImage()
		{
			imageAlpha=1
			_display=new Shape
			super();
		}
		override protected function onProppertiesUpdate():void
		{
			_drawImage();
			super.onProppertiesUpdate();
		}
		private function _drawImage():void{
			(_display as Shape).graphics.clear();
			(_display as Shape).graphics.beginFill(color,imageAlpha);
            switch(imageStyle){
				case CIRCLE:
					_buildCircle();
					break;
				case RECT:
					_buildRect();
					break;
			}
		}
		private function _buildCircle():void{
			(_display as Shape).graphics.drawEllipse(0,0,width,height);
			(_display as Shape).graphics.endFill();
		}
		private function _buildRect():void{
			(_display as Shape).graphics.drawRoundRect(0,0,width,height,ellipseWidth,ellipseHeight);
			(_display as Shape).graphics.endFill();
		}
	}
}